package org.csource.fastdfs.test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.commons.io.FileUtils;
import org.csource.common.MyException;
import org.csource.fastdfs.ClientGlobal;
import org.csource.fastdfs.StorageClient1;
import org.csource.fastdfs.StorageServer;
import org.csource.fastdfs.TrackerClient;
import org.csource.fastdfs.TrackerServer;

public class Client {
    public static void main(String[] args) throws FileNotFoundException, IOException, MyException {
        String conf = "src/test/resources/fastdfs-client.properties";
        byte[] b = FileUtils.readFileToByteArray(new File("src/test/resources/lady.jpg"));
        String url = "http://192.168.0.202/";
        //
        ClientGlobal.init(conf);
        TrackerClient tracker = new TrackerClient();
        TrackerServer trackerServer = tracker.getConnection();
        StorageServer storageServer = null;
        StorageClient1 client = new StorageClient1(trackerServer, storageServer);
//        for (int i = 0; i < 10; i++) {
            System.out.println(url + client.upload_file1(b, "jpg", null));
//        }
        trackerServer.close();
    }
}
